1. Field of the Invention
The present invention relates to an image processing apparatus, an image processing method, and a program, and more particularly, to an image processing apparatus generating a panoramic image from a plurality of images.
2. Description of the Related Art
Panoramic photography in which a panoramic image is generated from a plurality of images captured by performing continuous shooting while panning a camera is widely performed (for example, see Japanese Unexamined Patent Application Publication No. 2000-299804). A detailed example will be described below.
A user captures a plurality of images of a scene illustrated in FIG. 16 while panning a camera; that is, sequentially shifting a shooting position in the horizontal direction. For example, the user mounts the camera on a tripod capable of rotating in the horizontal direction and performs shooting while manually panning the camera in the horizontal direction. The scene in FIG. 16 includes buildings 300 and a walking person 301. When continuous shooting is performed in such a situation while panning the camera, N images P1 to PN illustrated in FIG. 17 can be captured, for example.
In FIG. 17, images P5 to PN-3 are not illustrated. Moreover, since the camera is moved in only the horizontal direction, actually no positional shift occurs in the Y-axis direction between the images but the positional shift occurs in only the X-axis direction. However, in the figure, the rectangular areas of the images P1 to PN are intentionally drawn so as to be slightly vertically shifted from each other because otherwise they overlap, thus becoming difficult to view. From these N images, one panoramic image (which is surrounded by a dot line in FIG. 17) Q is generated.
A method of generating a panoramic image Q from N input images P1 to PN is as follows. First, the positional relationship between the N input images P1 to PN is calculated. That is to say, the amount of shift between the input images is calculated. Then, the input images are arranged at positions shifted by the shift amount. In a state where the N input images P1 to PN are arranged to be shifted from each other, a rectangular area included in the N input images P1 to PN is calculated. This rectangular area is the panoramic image Q which is to be output.
Attention is now directed to each position (X, Y) of the panoramic image Q, when there is only one input image at that position (X, Y), the pixel value at the position (X, Y) of that input image is used as the pixel value at the position (X, Y) of the panoramic image Q. When there is a plurality of input images at that position (X, Y), the average of the pixel values at the position (X, Y) of these input images is used as the pixel value at the position (X, Y) of the panoramic image Q.